import QtQuick 2.15
import QtQml 2.0
import QtQuick.Controls 2.15

Rectangle{

    border.width: 1
    border.color: "#00AB84"
    radius: 10
    clip: true
    property ListModel lmodel:null
    property int moffset: 5

    Column {
        id: column
        anchors.fill: parent
        spacing: 5

        Rectangle{
            id:titlel
            height: 40
            width: parent.width

            anchors.leftMargin: moffset
            color: "#00AB84"
            radius: 10

            Text {
                anchors.centerIn: parent
                text: qsTr(lmodel.get(0)["devide"])
            }
        }

        ListView{
            id:listView
            clip: true
            model: lmodel

            width: parent.width - moffset*2
            height: parent.height - titlel.height - moffset*2

            ScrollBar.vertical: ScrollBar {
                id: vBar
                opacity: listView.contentHeight > listView.height ? 1.0 : 0.0
                visible: opacity > 0
                active: visible
            }
            //        section.property: "devide"
            //        section.delegate: Rectangle{
            //            height: 40
            //            width: parent.width
            //            color: "#00AB84"
            //            radius: 10
            //            Text {
            //                anchors.centerIn: parent
            //                anchors.margins: 5
            //                text: qsTr(section)
            //            }
            //        }
            delegate: Rectangle{
                height: 40
                width:  parent.width
                anchors.left: parent.left
                anchors.leftMargin: moffset
                Text {
                    id:lname
                    anchors.left: parent.left
                    anchors.leftMargin: 10
                    wrapMode: Text.WordWrap
                    text: qsTr(name)
                }
                Text {
                    id:lvalue
                    anchors.right: lunit.left
                    anchors.rightMargin: 10
                    wrapMode: Text.WordWrap
                    text: qsTr(String(value) )
                }
                Text {
                    id:lunit
                    width: 50
                    anchors.right: parent.right
                    anchors.rightMargin: 10
                    //                wrapMode: Text.WordWrap
                    text: qsTr(unit)
                }
            }

        }
    }
}

/*##^##
Designer {
    D{i:0;height:480;width:640}
}
##^##*/
